<template>
  <el-card class="me-area" :body-style="{ padding: '16px' }">
    <div class="me-article-header">
      <a :href="url" @click.prevent="view(articleId)" class="me-article-title">{{title}}</a>
      <el-button v-if="weight > 0" class="me-article-icon" type="text">置顶</el-button>
      <span class="me-pull-right me-article-count">
        <i class="el-icon-view"></i>
        &nbsp;{{readNumber}}
      </span>
    </div>
    <div class="me-artile-description">{{summary}}</div>

    <div class="me-article-footer">
      <span class="me-article-author">
        <i class="me-icon-author"></i>
        &nbsp;{{nickName}}
      </span>

      <el-button v-for="t in showTags" :key="t" type="primary" size="mini" round plain>{{t}}</el-button>

      <span class="me-pull-right me-article-count">
        <i class="el-icon-time"></i>
        &nbsp;{{createTime | parseTime}}
      </span>
    </div>
  </el-card>
</template>

<script>
export default {
  name: "ArticleItem",
  props: {
    articleId: Number,
    weight: Number,
    title: String,
    commentNumber: Number,
    readNumber: Number,
    summary: String,
    nickName: String,
    tags: String,
    createTime: Number
  },
  computed: {
    showTags: {
      get() {
        return this.tags != null ? this.tags.split(",") : null;
      },
      set(value) {}
    },
    url() {
      return `/view/` + this.articleId;
    }
  },
  data() {
    return {};
  },
  methods: {
    view(id) {
      this.$router.push({ path: `/view/${id}` });
    }
  }
};
</script>

<style scoped>
.me-article-header {
  /*padding: 10px 18px;*/
  padding-bottom: 10px;
}

.me-article-title {
  font-weight: 600;
}

.me-article-icon {
  padding: 3px 6px;
}

.me-article-count {
  padding-left: 8px;
  font-size: 13px;
}

.me-pull-right {
  float: right;
}

.me-artile-description {
  font-size: 13px;
  line-height: 24px;
  margin-bottom: 10px;
}

.me-article-author {
  padding-right: 18px;
  font-size: 13px;
}

.el-tag {
  margin-left: 6px;
}
</style>
